using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace WebTest;

public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args)
    {
        var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
        var isDevelopment = environment == Environments.Development;
        var server = Host.CreateDefaultBuilder(args).UseWindowsService();
        if (isDevelopment)
            return server.ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseUrls("http://*:5006");
                webBuilder.UseStartup<Startup>();
            });
        else
            return server.ConfigureWebHostDefaults(webBuilder =>
            {
                //webBuilder.ConfigureKestrel((context, options) =>
                //{
                //    // 设置应用服务器Kestrel请求体最大为100MB（默认30000000字节，约28.6M）
                //    options.Limits.MaxRequestBodySize = 104857600;
                //});
                webBuilder.UseUrls("http://*:80");
                webBuilder.UseStartup<Startup>();
            });
    }
}